const checkPhone = (phone) => {
	const phoneReg = /^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/

	return phoneReg.test(phone)
}

const checkPassword = (password) => {
	if(password.length<6) return false
	const reg = /^(.)\1*$/;
	const a = !reg.test(password);

	let valueArr = [];
	for (let i = 0; i < password.length; i++) {
		valueArr.push(password[i] * 1);
	}

	const valueArrlength = valueArr.length - 1;
	let b = false;
	for (let i = 0; i < valueArrlength; i++) {
		if (valueArr[i] !== valueArr[i + 1] - 1) {
			b = true;
			break;
		}
	}
	return a && b;
}

const checkText = text => {
	return text.trim().length >= 2 ? true : false
}

const checkId = text => {
	const idReg =
		/^[1-9]\d{7}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}$|^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}([0-9]|X)$/
	return idReg.test(text)
}
export {
	checkPhone,
	checkPassword,
	checkText,
	checkId
}
